from tkinter import *
from tkinter import messagebox
#创建主窗口
win = Tk()
win.config(bg='#8DB6CD')
win.title("猫咪式样判断APP")
win.geometry('400x300')
win.iconbitmap('D:/logs/favicon.ico')
lblMoney = Label (win, text='Money',width =10,font=('微软雅黑',10,'bold'))
lblMoney.grid(row=0,column=0)
txtMoney = Entry (win, width =20,font=('微软雅黑',10,'bold'))
txtMoney.grid(row=0,column=1,padx=5,pady=5)
lblArea = Label (win, text='State Name',width =10,font=('微软雅黑',10,'bold'))
lblArea.grid(row=1,column=0)
txtArea = Entry (win, width =20,font=('微软雅黑',10,'bold'))
txtArea.grid(row=1,column=1,padx=5,pady=5)
permitList = ['Alabama','California']
#判断结果
def judge():
    money=int(txtMoney.get())
    state=txtArea.get()
    result=0
    permit = isPermit(state)
    if permit==False:
        result=0
    else:
        if money<20:
            result=0
        elif money>=20 and money<40:
            result=1
        else:
            result=2
    if result==0:
        messagebox.showinfo("判定结果","You can't adopt a dog")
    elif result==1:
        messagebox.showinfo("判定结果","You can adopt one cat.")
    else:
        messagebox.showinfo("判定结果","You can adopt two cats.")
    
#输出结果
def isPermit(state):
    for st in permitList:
        if st == state:
            return True
    return False
button = Button(win,text='Judge',command=judge)
button.grid(row=3)
#开始程序循环
win .mainloop ()